﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IllustratedCsharp7_ch18Generic
{
    /*
        下面代码声明了一个叫作PieceOfData的泛型结构
     */
    struct PieceOfData<T>
    {
        private T _data;
        public PieceOfData(T value) { _data = value; }
        public T Data
        {
            get { return _data; }
            set { _data = value; }
        }
    }
    class Chapt18_7GenericStruct
    {
        static void _Main()
        {
            var intData = new PieceOfData<int>(10);
            var stringData = new PieceOfData<string>("Hi here.");
            Console.WriteLine($"intData     = {intData.Data}");
            Console.WriteLine($"stringData  = {stringData.Data}");
        }       
    }
}
